/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entity;

import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;

/**
 *
 * @author Randall Chia
 */
@Entity
public class RewardItem implements Serializable {
    private static long serialVersionUID = 1L;

    /**
     * @return the serialVersionUID
     */
    public static long getSerialVersionUID() {
        return serialVersionUID;
    }

    /**
     * @param aSerialVersionUID the serialVersionUID to set
     */
    public static void setSerialVersionUID(long aSerialVersionUID) {
        serialVersionUID = aSerialVersionUID;
    }
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (getId() != null ? getId().hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof RewardItem)) {
            return false;
        }
        RewardItem other = (RewardItem) object;
        if ((this.getId() == null && other.getId() != null) || (this.getId() != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Entity.RewardItem[ id=" + getId() + " ]";
    }

    
    // =================================================================================================================== 
    private String stakeholder;
    private String reward_Name;
//    @Column(columnDefinition = "LONGTEXT")
    private String reward_Description;
    private Integer reward_Cost;         //the number of points needed to redeem this reward
    private Integer vouchers_left;       //the maximum number of times this reward can be redeemed. 
    private boolean unlimitedVouchers;
    // ===================================================================================================================
    
    public RewardItem(){}
    
    public RewardItem(
                 String stakeholder,
                 String reward_Name,
                 String reward_Description,
                 Integer reward_Cost,
                 Integer vouchers_left,
                 boolean unlimitedVouchers
            ){
        this.stakeholder = stakeholder;
        this.reward_Name = reward_Name;
        this.reward_Description = reward_Description;
        this.reward_Cost = reward_Cost;
        this.vouchers_left = vouchers_left;
        this.unlimitedVouchers = unlimitedVouchers;
    }
    
        
    
    public String getRemainingVouchers(){
        if(this.unlimitedVouchers == true) return "unlimited";
        else return vouchers_left + "";
    }
    
    public void decrementVoucher(){
        this.vouchers_left--;
    }
    
    
    
    
    

    /**
     * @return the stakeholder
     */
    public String getStakeholder() {
        return stakeholder;
    }

    /**
     * @param stakeholder the stakeholder to set
     */
    public void setStakeholder(String stakeholder) {
        this.stakeholder = stakeholder;
    }

    /**
     * @return the reward_Name
     */
    public String getReward_Name() {
        return reward_Name;
    }

    /**
     * @param reward_Name the reward_Name to set
     */
    public void setReward_Name(String reward_Name) {
        this.reward_Name = reward_Name;
    }

    /**
     * @return the reward_Description
     */
    public String getReward_Description() {
        return reward_Description;
    }

    /**
     * @param reward_Description the reward_Description to set
     */
    public void setReward_Description(String reward_Description) {
        this.reward_Description = reward_Description;
    }

    /**
     * @return the reward_Cost
     */
    public Integer getReward_Cost() {
        return reward_Cost;
    }

    /**
     * @param reward_Cost the reward_Cost to set
     */
    public void setReward_Cost(Integer reward_Cost) {
        this.reward_Cost = reward_Cost;
    }

    /**
     * @return the vouchers_left
     */
    public Integer getVouchers_left() {
        return vouchers_left;
    }

    /**
     * @param vouchers_left the vouchers_left to set
     */
    public void setVouchers_left(Integer vouchers_left) {
        this.vouchers_left = vouchers_left;
    }

    /**
     * @return the unlimitedVouchers
     */
    public boolean isUnlimitedVouchers() {
        return unlimitedVouchers;
    }

    /**
     * @param unlimitedVouchers the unlimitedVouchers to set
     */
    public void setUnlimitedVouchers(boolean unlimitedVouchers) {
        this.unlimitedVouchers = unlimitedVouchers;
    }
    
    
    
    
    
}
